<template>
  <div>
    <div :[attributeName]="d1"></div>
    <button @click="change">点击切换</button>
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  props: {},
  data() {
    return {
      attributeName: "class",
      d1: "d1",
    };
  },
  methods:{
    change() {
      this.attributeName = "id",
      this.d1 = "d2"
    }
  }
};
</script>

<style>
.d1 {
  width: 100px;
  height: 100px;
  background: yellow;
}
#d2 {
  width: 100px;
  height: 100px;
  background: green;
}
</style>